<?php
namespace app\controllers\api\post;

use fate\http\Request;
use app\models\Posts;

class GetController extends \fate\web\PureController {

    public function run() {
        $req = Request::getInstance();

        $id = $_GET['id'];
        if(!is_numeric($id)) {
            $this->ajaxReturn(null, 300002);
            exit;
        }

        $data = (new Posts())->getOneByCondition(
            'id,uid,title,tags,thumb,brief,views,post_time,status',
            'id=' . $id);

        if(null === $data) {
            $this->ajaxReturn(null, 400001);
            exit;
        }

        $this->ajaxReturn([
            'data' => $data
        ]);
    }

}
